import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-03
 * Time: 12:49
 */
public class Test10 {
    public static int subNum(int[] num, int k) {
        // 和,个数
        Map<Integer,Integer> hash = new HashMap<>();
        // 特殊处理
        hash.put(0,1);
        int ret = 0;
        int sum = 0;
        for(int i = 0; i < num.length; i++) {
            sum += num[i];
            ret += hash.getOrDefault(sum-k,0);
            hash.put(sum,hash.getOrDefault(sum,0)+1);
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n;i++) {
            num[i]  = sc.nextInt();
        }
        int k = sc.nextInt();
        int ret = subNum(num,k);
        System.out.println("和为k的子数组个数："+ret);
    }
}
